def get_k_range(nums,k):
    prefix_sums = [0] * (len(nums) + 1)
    prefix_sums_mod = {}
    prefix_sums_mod[0] = 1
    for i in range(1, len(nums) + 1):
        prefix_sums[i] = prefix_sums[i - 1] + nums[i - 1]  # 计算前缀和
        mod = prefix_sums[i] % k  # 对前缀和取模
        if mod in prefix_sums_mod:
            prefix_sums_mod[mod] += 1
        else:
            prefix_sums_mod[mod] = 1

    # 同余做差一定为k的倍数，说明这个差所代表的区间和一定是k的倍数
    count = 0
    for j in range(0,k):
        if j not in prefix_sums_mod:
            prefix_sums_mod[j] = 0
        count += (prefix_sums_mod[j] * (prefix_sums_mod[j] - 1)) // 2
    return count



number,k = map(int,input().split())
nums = []
for i in range(number):
    num = int(input())
    nums.append(num)

print(get_k_range(nums,k))
